<%--
  Created by IntelliJ IDEA.
  User: parttime
  Date: 2017/8/19
  Time: 下午16:05
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../../resources.jsp" %>


<html>
<head>
    <title>用户反馈</title>
</head>
<body>
<div>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">查询条件</h3>
        </div>
        <div class="panel-body">
            <form class="form-inline">
                <div class="form-group">
                    <%--<label for="nick_name">昵称：</label>--%>
                    <input type="text" class="form-control" id="nick_name" name="nick_name"  placeholder="昵称">
                </div>
                <%--<div class="form-group">--%>
                    <%--&lt;%&ndash;<label for="status">状态：</label>&ndash;%&gt;--%>
                    <%--<select id="status" name="status" class="form-control">--%>
                        <%--<option value = "">请选择</option>--%>
                        <%--<option value ="0">反馈失败</option>--%>
                        <%--<option value ="1">反馈成功</option>--%>
                    <%--</select>--%>
                <%--</div>--%>
                <div class="form-group">
                    <button type="button" id="btn-search" class="btn btn-info">查询</button>
                    <button type="button" class="btn btn-reset btn-default">清空</button>
                </div>
            </form>
        </div>
    </div>
</div>

<div class="ems_table_content">
    <div class="panel panel-default">
        <div class="panel-heading">用户反馈</div>
        <div id="table_tools">
            <div class="form-inline" role="form">
                <button type="button" id="feedback_image" class="btn btn-outline btn-success">
                    <i class="glyphicon glyphicon-plus" aria-hidden="true"></i>
                    查看反馈图片
                </button>
                <%--<button type="button" id="feedback_modify" class="btn btn-outline btn-primary">--%>
                    <%--<i class="glyphicon glyphicon-edit" aria-hidden="true"></i>--%>
                    <%--修改--%>
                <%--</button>--%>
                <%--<button type="button" id="feedback_delete" class="btn btn-outline btn-danger">--%>
                    <%--<i class="glyphicon glyphicon-trash" aria-hidden="true"></i>--%>
                    <%--删除--%>
                <%--</button>--%>
            </div>
        </div>
        <table id="feedBackTable"
               data-url="/ems/feedback/pagination"
               data-show-export="true">
            <thead>
            <tr>
                <th data-field="state" data-checkbox="true"></th>
                <th data-field="nick_name" data-width="100px">昵称</th>
                <th data-field="content">内容</th>
                <th data-field="status" data-width="80px" data-formatter="statusFormat">状态</th>
                <th data-field="feedback_time" data-width="150px">反馈时间</th>
            </tr>
            </thead>

        </table>
    </div>
</div>

<script>
    $(function () {
        $("#feedBackTable").createTable();

        //搜索
        $("#btn-search").on("click",function () {
            search(getQueryParams());
        });

        var dialogOption = {
            width:"500px",
            height:"450px",
            url:"/ems/feedback/image",
            yesFn:function(){
                return true;
            }
        }

        $("#feedback_image").on("click",function(){

            var selectRows =  $('#feedBackTable').bootstrapTable('getSelections');
            if (selectRows.length == 0) {
                $.errorAlert("请选择要查看的数据");
                return;
            }
            if (selectRows.length > 1) {
                $.errorAlert("暂时不支持多行数据审核");
                return;
            }

            var rowId =  selectRows[0].id;
            dialogOption.title = "反馈图片";
            dialogOption.data = {feedbackId : rowId};
            $("#feedback_image_dialog").openDialog(dialogOption);

        })
    })

</script>


<script>
    function statusFormat(srcValue) {
        if (srcValue == 0) {
            return "<span style='color: red;font-weight: bold' >反馈失败</span>";
        } else if(srcValue == 1) {
            return "<span style='color: #3cb371;font-weight: bold'>反馈成功</span>";
        }
    }

    function search(params) {
        var queryParams = {"query":params};
        $('#feedBackTable').bootstrapTable('refresh', queryParams);
    }

</script>
<div id="feedback_image_dialog"></div>
</body>
</html>
